#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2019/12/30 15:13
# @Author  : Wentworth

import cv2 as cv

filename = r"lena.jpg"
img = cv.imread(filename)

Gauss = cv.GaussianBlur(img, (5,5),0)
image1 = cv.resize(img, (int(img.shape[1]/2),int(img.shape[0]/2)))
image2 = cv.pyrDown(image1)
gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
_ , gray1 = cv.threshold(gray, 120, 0xff, cv.THRESH_BINARY)

cv.imshow("source image" , img)
cv.imshow("Gaussian", Gauss)
cv.imshow("half", image1)
cv.imshow("quater", image2)
cv.imshow("gray",gray)
cv.imshow("threshold", gray1)
cv.waitKey()

hsv = cv.cvtColor(img,cv.COLOR_BGR2HSV)

cv.imshow("Hue", hsv[:, :, 0]) # 色度
cv.imshow("Saturation", hsv[:, :, 1]) #饱和度
cv.imshow("Value", hsv[:, :, 2]) # 亮度
cv.waitKey()

cv.imshow("Blue", img[:, :, 0])
cv.imshow("Green", img[:, :, 1])
cv.imshow("Red", img[:, :, 2])

cv.waitKey()
cv.destroyAllWindows()